home *** CD-ROM | disk | FTP | other *** search
/ SuperHack / SuperHack CD.bin / CODING / DELPHI / NWLIB.ZIP / DEMO.ZIP / USERSTAT.PAS < prev   
Encoding:
Pascal/Delphi Source File  |  1996-08-12  |  3.7 KB  |  141 lines

  1. unit Userstat;
  2.  
  3. interface
  4.  
  5. uses 
  6.      SysUtils,
  7.      WinTypes, 
  8.      WinProcs, 
  9.      Classes, 
  10.      Graphics, 
  11.      Forms, 
  12.      Controls, 
  13.      Buttons,
  14.      StdCtrls, 
  15.      ExtCtrls,
  16.      NWLib, 
  17.      NWTools, 
  18.      NWServer; 
  19.  
  20. type
  21.   TwinUserStats = class(TForm)
  22.     CancelBtn: TBitBtn;
  23.     Bevel1: TBevel;
  24.     Label1: TLabel;
  25.     Label3: TLabel;
  26.     Label4: TLabel;
  27.     Label5: TLabel;
  28.     netName: TEdit;
  29.     fullUserName: TEdit;
  30.     netAddrs: TComboBox;
  31.     stationAddrs: TComboBox;
  32.     StatTimer: TTimer;
  33.     bPause: TBitBtn;
  34.     NWLib1: TNWLib;
  35.     NWTools1: TNWTools;
  36.     NWServer1: TNWServer;
  37.     net4Info: TGroupBox;
  38.     Label6: TLabel;
  39.     Label7: TLabel;
  40.     Label8: TLabel;
  41.     Label9: TLabel;
  42.     Label10: TLabel;
  43.     bytesRead: TEdit;
  44.     bytesWritten: TEdit;
  45.     Requests: TEdit;
  46.     recordLocks: TEdit;
  47.     fileLocks: TEdit;
  48.     Label2: TLabel;
  49.     loginTime: TEdit;
  50.     procedure bPauseClick(Sender: TObject);
  51.     procedure StatTimerTimer(Sender: TObject);
  52.     procedure FormShow(Sender: TObject);
  53.   private
  54.     { Private declarations }
  55.   public
  56.     { Public declarations }
  57.     procedure statsUpdate ;
  58.   end;
  59.  
  60. var
  61.   winUserStats: TwinUserStats;
  62.  
  63. implementation
  64.  
  65. {$R *.DFM}
  66.  
  67. procedure TwinUserStats.FormShow(Sender: TObject);
  68.   var
  69.     connectInfo : TNWConnectInfo ;
  70.     connList    : TConnList      ;
  71.     nConns      : word           ;
  72.     nLoop       : word           ;
  73.   begin
  74.     {Get User's Login Connection List, then look at on each one }
  75.     nConns := 0 ;
  76.     getUserConnList(getPrimaryServerID,netName.text,nConns,connList) ;
  77.     for nloop := 1 to nConns do begin
  78.       if getConnectInfo(getPrimaryServerID, 
  79.                         connList[nloop-1],
  80.                         connectInfo) then
  81.         begin
  82.           fullUserName.text := fullName(0,netname.text) + ' @ ' +
  83.                                connectInfo.serverName ;
  84.           { Add Items to ComboBoxes }
  85.           netAddrs.items.add(connectInfo.internet) ;
  86.           stationAddrs.items.add(intToStr(connList[nloop-1])) ;
  87.         end;  
  88.     end;
  89.     loginTime.text    := dateTimeToStr(connectInfo.loginDateTime)  ;
  90.     netAddrs.text     := netaddrs.items[0] ;
  91.     stationAddrs.text := stationAddrs.items[0] ;
  92.     { if only one item, change combobox style }
  93.     if (netAddrs.items.count < 2) then
  94.       netAddrs.style := csSimple ;
  95.     if (stationAddrs.items.count < 2) then
  96.       stationAddrs.style := csSimple ;
  97.  
  98.     { initial timer event }
  99.     statsUpdate ;
  100.   end;
  101.  
  102. procedure TwinUserStats.bPauseClick(Sender: TObject);
  103.   begin
  104.     statTimer.enabled := (not statTimer.enabled) ;
  105.     if not statTimer.enabled then
  106.       bPause.caption := '&Resume' 
  107.     else
  108.       bPause.caption := '&Pause' ; 
  109.   end;
  110.  
  111. procedure TwinUserStats.StatTimerTimer(Sender: TObject);
  112.   begin
  113.     statsUpdate ;
  114.   end;
  115.  
  116. procedure TWinUserStats.statsUpdate ;
  117.   var
  118.     connStats : TNWConnStats ;      { public netware struct. }
  119.   begin
  120.     if getUserStats(GetPrimaryServerID,
  121.                     strToIntDef(stationAddrs.items[maxLong(stationAddrs.itemIndex,0)],0),
  122.                     connStats) then 
  123.       begin
  124.         bytesRead.text    := intToStr(connStats.bytesRead)     ;
  125.         bytesWritten.text := intToStr(connStats.bytesWritten)  ;
  126.         requests.text     := intToStr(connStats.totalRequests) ;
  127.         recordLocks.text  := intToStr(connStats.recordLocks)   ;
  128.         fileLocks.text    := intToStr(connStats.fileLocks)     ;
  129.       end                              
  130.     else
  131.       begin
  132.         bytesRead.text    := '0' ;
  133.         bytesWritten.text := '0' ;
  134.         requests.text     := '0' ;
  135.         recordLocks.text  := '0' ;
  136.         fileLocks.text    := '0' ;
  137.       end;                   
  138.   end;
  139.  
  140. end.
  141.